package www.openteam.com.adapter.bussiness;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import www.openteam.com.R;
import www.openteam.com.bean.CoShipBusAllLst;
import www.openteam.com.bean.LdLst_dlrtNote;
import www.openteam.com.bean.ShipBusList;

/**
 * Created by Administrator on 2019-10-30.
 */

public class LoadingLstAdp extends RecyclerView.Adapter<LoadingLstAdp.ViewHodler> {

    Context context;
    List<LdLst_dlrtNote> mSortedList = new ArrayList<>();


    public LoadingLstAdp(Context context) {
        this.context = context;
    }


    public void setmSortedList(List<LdLst_dlrtNote> mSortedList) {
        this.mSortedList = mSortedList;
    }

    @Override
    public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_loadlst_dlernote, parent, false);
        return new ViewHodler(view);
    }

    @Override
    public void onBindViewHolder(ViewHodler holder, int position) {
        LdLst_dlrtNote dataBean = mSortedList.get(position);
        holder.sendNo.setText(dataBean.getSendNo());
        holder.custid.setText(dataBean.getCustid());
        holder.sendAddress.setText(dataBean.getSendAddress());
        holder.boxNumb.setText(dataBean.getBoxNumb() + "");
        holder.boxPackages.setText(dataBean.getBoxPackages() + "");

    }

    public void removeItem(int position) {
        mSortedList.remove(mSortedList.get(position));
        notifyDataSetChanged();
    }

    public void addItem(LdLst_dlrtNote pd) {
        mSortedList.add(pd);
        notifyDataSetChanged();

    }

    public void clear() {
        mSortedList.clear();
        notifyDataSetChanged();

    }

    public String getSendNo(int position) {
        return mSortedList.get(position).getSendNo();

    }

    public CoShipBusAllLst getcoShipAllBus(int position) {
        CoShipBusAllLst coShipBusAllLst = new CoShipBusAllLst();
        LdLst_dlrtNote ldLst_dlrtNote = mSortedList.get(position);
        coShipBusAllLst.setId(ldLst_dlrtNote.getId());
        coShipBusAllLst.setZbid(ldLst_dlrtNote.getZbid());
        coShipBusAllLst.setSendNo(ldLst_dlrtNote.getSendNo());
        return coShipBusAllLst;

    }

    @Override
    public int getItemCount() {
        return mSortedList.size();
    }

    public static class ViewHodler extends RecyclerView.ViewHolder {
        @Bind(R.id.item_load_lst_SendNo)
        TextView sendNo;
        @Bind(R.id.item_load_lst_custid)
        TextView custid;
        @Bind(R.id.item_load_lst_SendAddress)
        TextView sendAddress;
        @Bind(R.id.item_load_lst_BoxNumb)
        TextView boxNumb;
        @Bind(R.id.item_load_lst_BoxPackages)
        TextView boxPackages;
        @Bind(R.id.lineitem)
        public LinearLayout lineitem;
        @Bind(R.id.a_card)
        public CardView aCard;
        @Bind(R.id.item_delete)
        public TextView item_delete;


        public ViewHodler(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
